package com.seven.good.scheduler;

import com.seven.good.dao.GoodMapper;
import com.seven.good.pojo.Good;
import com.seven.good.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
public class RecommendScheduler {

    @Autowired
    RedisTemplate redisTemplate;

    @Autowired
    GoodService goodService;

    @Autowired
    GoodMapper goodMapper;

    /**
     * @Description：定时任务，每半小时更新推荐商品
     * @Author: ytj
     * @CreateDate:  19/10/17
     */
    //@Scheduled(cron = "0 0/30 * * * ? ")
    public void updateRecommend(){
        System.out.println("----->");
        redisTemplate.delete("recommend");
        goodService.listGoodsByCircuseeNo();
        goodService.listGoodsByBidNo();
        goodService.listGoodsBySignUpNo();
        /*redisTemplate.execute(new RedisCallback() {
            @Override
            public Object doInRedis(RedisConnection redisConnection) throws DataAccessException {
                redisConnection.ttl()
                return null;
            }
        });*/
    }
}
